//validates the list name so it can be saved into the repository
function valid_list_name(name) {
	var re = new RegExp("(.*[\"\*\\\>\<\?\/\:\|]+.*)|(.*[\.]?.*[\.]+$)|(.*[ ]+$)");
	if (name.match(re)) {
		return false;
	}
	else {
		return true;
	}
}

// gets a search condition from a savedSearch
function getValue(name) {
	return (args[name] != undefined) ? name + ":" + args[name] : "";
}

// Creates all the folders that are needed
function createFolders() {
	// Creates vgr folder in companyhome if it does not exists.
	vgr = companyhome.childByNamePath("vgr");
	if (vgr == null && companyhome.hasPermission("CreateChildren")) {
	   vgr = companyhome.createFolder("vgr");
	}
	
	// Creates published folder within the vgr folder if it does not exists. 
	publishedFolder = vgr.childByNamePath("published");
	if (publishedFolder == null && vgr.hasPermission("CreateChildren")) {
	   publishedFolder = vgr.createFolder("published");
	}

	// Creates Saved Searches folder within the vgr folder if it does not exists. 
	savedSearchesFolder = vgr.childByNamePath("Saved Searches");
	if (savedSearchesFolder == null && vgr.hasPermission("CreateChildren")) {
		savedSearchesFolder = vgr.createFolder("Saved Searches");
	}

	// Creates preview folder within the Saved Searches folder if it does not exists.
	previewFolder = savedSearchesFolder.childByNamePath("preview");
	if (previewFolder == null && savedSearchesFolder.hasPermission("CreateChildren")) {
		previewFolder = savedSearchesFolder.createFolder("preview");
	}
}